home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / cc / dist / expmed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-13  |  51.7 KB  |  1,641 lines

  1. /* Medium-level subroutines: convert bit-field store and extract
  2.    and shifts, multiplies and divides to rtl instructions.
  3.    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 1, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. #include "config.h"
  23. #include "rtl.h"
  24. #include "tree.h"
  25. #include "flags.h"
  26. #include "insn-flags.h"
  27. #include "insn-codes.h"
  28. #include "insn-config.h"
  29. #include "expr.h"
  30. #include "recog.h"
  31.  
  32. static rtx extract_split_bit_field ();
  33. static rtx extract_fixed_bit_field ();
  34. static void store_split_bit_field ();
  35. static void store_fixed_bit_field ();
  36.  
  37. /* Return an rtx representing minus the value of X.
  38.    MODE is the intended mode of the result,
  39.    useful if X is a CONST_INT.  */
  40.  
  41. rtx
  42. negate_rtx (mode, x)
  43.      enum machine_mode mode;
  44.      rtx x;
  45. {
  46.   if (GET_CODE (x) == CONST_INT)
  47.     {
  48.       int val = - INTVAL (x);
  49.       if (GET_MODE_BITSIZE (mode) < HOST_BITS_PER_INT)
  50.     {
  51.       /* Sign extend the value from the bits that are significant.  */
  52.       if (val & (1 << (GET_MODE_BITSIZE (mode) - 1)))
  53.         val |= (-1) << GET_MODE_BITSIZE (mode);
  54.       else
  55.         val &= (1 << GET_MODE_BITSIZE (mode)) - 1;
  56.     }
  57.       return gen_rtx (CONST_INT, VOIDmode, val);
  58.     }
  59.   else
  60.     return expand_unop (GET_MODE (x), neg_optab, x, 0, 0);
  61. }
  62.  
  63. /* Generate code to store value from rtx VALUE
  64.    into a bit-field within structure STR_RTX
  65.    containing BITSIZE bits starting at bit BITNUM.
  66.    FIELDMODE is the machine-mode of the FIELD_DECL node for this field.
  67.    ALIGN is the alignment that STR_RTX is known to have, measured in bytes.  */
  68.  
  69. rtx
  70. store_bit_field (str_rtx, bitsize, bitnum, fieldmode, value, align)
  71.      rtx str_rtx;
  72.      register int bitsize;
  73.      int bitnum;
  74.      enum machine_mode fieldmode;
  75.      rtx value;
  76.      int align;
  77. {
  78.   int unit = (GET_CODE (str_rtx) == MEM) ? BITS_PER_UNIT : BITS_PER_WORD;
  79.   register int offset = bitnum / unit;
  80.   register int bitpos = bitnum % unit;
  81.   register rtx op0 = str_rtx;
  82.   rtx value1;
  83.  
  84.   while (GET_CODE (op0) == SUBREG)
  85.     {
  86.       offset += SUBREG_WORD (op0);
  87.       op0 = SUBREG_REG (op0);
  88.     }
  89.  
  90.   value = protect_from_queue (value, 0);
  91.  
  92.   if (flag_force_mem)
  93.     value = force_not_mem (value);
  94.  
  95.   if (GET_MODE_SIZE (fieldmode) >= UNITS_PER_WORD)
  96.     {
  97.       /* Storing in a full-word or multi-word field in a register
  98.      can be done with just SUBREG.  */
  99.       if (GET_MODE (op0) != fieldmode)
  100.     op0 = gen_rtx (SUBREG, fieldmode, op0, offset);
  101.       emit_move_insn (op0, value);
  102.       return value;
  103.     }
  104.  
  105. #ifdef BYTES_BIG_ENDIAN
  106.   /* If OP0 is a register, BITPOS must count within a word.
  107.      But as we have it, it counts within whatever size OP0 now has.
  108.      On a bigendian machine, these are not the same, so convert.  */
  109.   if (GET_CODE (op0) != MEM && unit > GET_MODE_BITSIZE (GET_MODE (op0)))
  110.     bitpos += unit - GET_MODE_BITSIZE (GET_MODE (op0));
  111. #endif
  112.  
  113.   /* Storing an lsb-aligned field in a register
  114.      can be done with a movestrict instruction.  */
  115.  
  116.   if (GET_CODE (op0) != MEM
  117. #ifdef BYTES_BIG_ENDIAN
  118.       && bitpos + bitsize == unit
  119. #else
  120.       && bitpos == 0
  121. #endif
  122.       && (GET_MODE (op0) == fieldmode
  123.       || (movstrict_optab->handlers[(int) fieldmode].insn_code
  124.           != CODE_FOR_nothing)))
  125.     {
  126.       /* Get appropriate low part of the value being stored.  */
  127.       if (GET_CODE (value) == CONST_INT || GET_CODE (value) == REG)
  128.     value = gen_lowpart (fieldmode, value);
  129.       else if (!(GET_CODE (value) == SYMBOL_REF
  130.          || GET_CODE (value) == LABEL_REF
  131.          || GET_CODE (value) == CONST))
  132.     value = convert_to_mode (fieldmode, value, 0);
  133.  
  134.       if (GET_MODE (op0) == fieldmode)
  135.     emit_move_insn (op0, value);
  136.       else
  137.     emit_insn (GEN_FCN (movstrict_optab->handlers[(int) fieldmode].insn_code)
  138.            (gen_rtx (SUBREG, fieldmode, op0, offset), value));
  139.  
  140.       return value;
  141.     }
  142.  
  143.   /* From here on we can assume that the field to be stored in is an integer,
  144.      since it is shorter than a word.  */
  145.  
  146.   /* OFFSET is the number of words or bytes (UNIT says which)
  147.      from STR_RTX to the first word or byte containing part of the field.  */
  148.  
  149.   if (GET_CODE (op0) == REG)
  150.     {
  151.       if (offset != 0
  152.       || GET_MODE_SIZE (GET_MODE (op0)) > GET_MODE_SIZE (SImode))
  153.     op0 = gen_rtx (SUBREG, SImode, op0, offset);
  154.       offset = 0;
  155.     }
  156.   else
  157.     {
  158.       op0 = protect_from_queue (op0, 1);
  159.     }
  160.  
  161.   /* Now OFFSET is nonzero only if OP0 is memory
  162.      and is therefore always measured in bytes.  */
  163.  
  164. #ifdef HAVE_insv
  165.   if (HAVE_insv
  166.       && !(bitsize == 1 && GET_CODE (value) == CONST_INT))
  167.     {
  168.       int xbitpos = bitpos;
  169.       rtx xop0 = op0;
  170.       rtx last = get_last_insn ();
  171.       rtx pat;
  172.  
  173.       /* If this machine's insv can only insert into a register,
  174.      copy OP0 into a register and save it back later.  */
  175.       if (GET_CODE (op0) == MEM
  176.       && ! (*insn_operand_predicate[(int) CODE_FOR_insv][0]) (op0, VOIDmode))
  177.     {
  178.       rtx tempreg;
  179.       enum machine_mode trymode, bestmode = VOIDmode, insn_mode;
  180.       int maxsize = GET_MODE_SIZE (insn_operand_mode[(int) CODE_FOR_insv][0]);
  181.  
  182.       /* Find biggest machine mode we can safely use
  183.          to fetch from this structure.
  184.          But don't use a bigger mode than the insn wants.  */
  185.       for (trymode = QImode;
  186.            trymode && GET_MODE_SIZE (trymode) <= maxsize;
  187.            trymode = GET_MODE_WIDER_MODE (trymode))
  188.         if (GET_MODE_SIZE (trymode) <= align)
  189.           bestmode = trymode;
  190.       if (! bestmode)
  191.         abort ();
  192.       /* Adjust address to point to the containing unit of that mode.  */
  193.       unit = GET_MODE_BITSIZE (bestmode);
  194.       /* Compute offset as multiple of this unit, counting in bytes.  */
  195.       offset = (bitnum / unit) * GET_MODE_SIZE (bestmode);
  196.       bitpos = bitnum % unit;
  197.       op0 = change_address (op0, bestmode, 
  198.                 plus_constant (XEXP (op0, 0), offset));
  199.  
  200.       /* Fetch that unit, store the bitfield in it, then store the unit.  */
  201.       tempreg = copy_to_reg (op0);
  202.       /* To actually store in TEMPREG,
  203.          look at it in the mode this insn calls for.
  204.          (Probably SImode.)  */
  205.       insn_mode = insn_operand_mode[(int) CODE_FOR_insv][0];
  206. #ifdef BITS_BIG_ENDIAN
  207.       if (GET_MODE_BITSIZE (insn_mode) > unit)
  208.         bitpos += GET_MODE_BITSIZE (insn_mode) - unit;
  209. #endif
  210.       store_bit_field (gen_rtx (SUBREG, insn_mode, tempreg, 0),
  211.                bitsize, bitpos, fieldmode, value, align);
  212.       emit_move_insn (op0, tempreg);
  213.       return value;
  214.     }
  215.  
  216.       /* Add OFFSET into OP0's address.  */
  217.       if (GET_CODE (xop0) == MEM)
  218.     xop0 = change_address (xop0, QImode,
  219.                    plus_constant (XEXP (xop0, 0), offset));
  220.  
  221.       /* If xop0 is a register, we need it in SImode
  222.      to make it acceptable to the format of insv.  */
  223.       if (GET_CODE (xop0) == SUBREG)
  224.     PUT_MODE (xop0, SImode);
  225.       if (GET_CODE (xop0) == REG && GET_MODE (xop0) != SImode)
  226.     xop0 = gen_rtx (SUBREG, SImode, xop0, 0);
  227.  
  228.       /* Convert VALUE to SImode (which insv insn wants) in VALUE1.  */
  229.       value1 = value;
  230.       if (GET_MODE (value) != SImode)
  231.     {
  232.       if (GET_MODE_BITSIZE (GET_MODE (value)) >= bitsize)
  233.         {
  234.           /* Optimization: Don't bother really extending VALUE
  235.          if it has all the bits we will actually use.  */
  236.  
  237.           /* Avoid making subreg of a subreg, or of a mem.  */
  238.           if (GET_CODE (value1) != REG)
  239.         value1 = copy_to_reg (value1);
  240.           value1 = gen_rtx (SUBREG, SImode, value1, 0);
  241.         }
  242.       else if (!CONSTANT_P (value))
  243.         /* Parse phase is supposed to make VALUE's data type
  244.            match that of the component reference, which is a type
  245.            at least as wide as the field; so VALUE should have
  246.            a mode that corresponds to that type.  */
  247.         abort ();
  248.     }
  249.  
  250.       /* If this machine's insv insists on a register,
  251.      get VALUE1 into a register.  */
  252.       if (! (*insn_operand_predicate[(int) CODE_FOR_insv][3]) (value1, SImode))
  253.     value1 = force_reg (SImode, value1);
  254.  
  255.       /* On big-endian machines, we count bits from the most significant.
  256.      If the bit field insn does not, we must invert.  */
  257.  
  258. #if defined (BITS_BIG_ENDIAN) != defined (BYTES_BIG_ENDIAN)
  259.       xbitpos = unit - 1 - xbitpos;
  260. #endif
  261.  
  262.       pat = gen_insv (xop0,
  263.               gen_rtx (CONST_INT, VOIDmode, bitsize),
  264.               gen_rtx (CONST_INT, VOIDmode, xbitpos),
  265.               value1);
  266.       if (pat)
  267.     emit_insn (pat);
  268.       else
  269.         {
  270.       delete_insns_since (last);
  271.       store_fixed_bit_field (op0, offset, bitsize, bitpos, value, align);
  272.     }
  273.     }
  274.   else
  275. #endif
  276.     /* Insv is not available; store using shifts and boolean ops.  */
  277.     store_fixed_bit_field (op0, offset, bitsize, bitpos, value, align);
  278.   return value;
  279. }
  280.  
  281. /* Use shifts and boolean operations to store VALUE
  282.    into a bit field of width BITSIZE
  283.    in a memory location specified by OP0 except offset by OFFSET bytes.
  284.      (OFFSET must be 0 if OP0 is a register.)
  285.    The field starts at position BITPOS within the byte.
  286.     (If OP0 is a register, it may be SImode or a narrower mode,
  287.      but BITPOS still counts within a full word,
  288.      which is significant on bigendian machines.)
  289.    STRUCT_ALIGN is the alignment the structure is known to have (in bytes).
  290.  
  291.    Note that protect_from_queue has already been done on OP0 and VALUE.  */
  292.  
  293. static void
  294. store_fixed_bit_field (op0, offset, bitsize, bitpos, value, struct_align)
  295.      register rtx op0;
  296.      register int offset, bitsize, bitpos;
  297.      register rtx value;
  298.      int struct_align;
  299. {
  300.   register enum machine_mode mode;
  301.   int total_bits = BITS_PER_WORD;
  302.   rtx subtarget;
  303.   int all_zero = 0;
  304.   int all_one = 0;
  305.  
  306.   /* Add OFFSET to OP0's address (if it is in memory)
  307.      and if a single byte contains the whole bit field
  308.      change OP0 to a byte.  */
  309.  
  310.   /* There is a case not handled here:
  311.      a structure with a known alignment of just a halfword
  312.      and a field split across two aligned halfwords within the structure.
  313.      Or likewise a structure with a known alignment of just a byte
  314.      and a field split across two bytes.
  315.      Such cases are not supposed to be able to occur.  */
  316.  
  317.   if (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG)
  318.     {
  319.       if (offset != 0)
  320.     abort ();
  321.       /* Special treatment for a bit field split across two registers.  */
  322.       if (bitsize + bitpos > BITS_PER_WORD)
  323.     {
  324.       store_split_bit_field (op0, bitsize, bitpos, value, BITS_PER_WORD);
  325.       return;
  326.     }
  327.     }
  328.   else if (bitsize + bitpos <= BITS_PER_UNIT
  329.        && (! SLOW_BYTE_ACCESS
  330.            || (struct_align == 1
  331.            && BIGGEST_ALIGNMENT > 1)))
  332.     {
  333.       /* It fits in one byte, and either bytes are fast
  334.      or the alignment won't let us use anything bigger.  */
  335.       total_bits = BITS_PER_UNIT;
  336.       op0 = change_address (op0, QImode, 
  337.                 plus_constant (XEXP (op0, 0), offset));
  338.     }
  339.   else if ((bitsize + bitpos + (offset % GET_MODE_SIZE (HImode)) * BITS_PER_UNIT
  340.         <= GET_MODE_BITSIZE (HImode))
  341.        /* If halfwords are fast, use them whenever valid.  */
  342.        && (! SLOW_BYTE_ACCESS
  343.            /* Use halfwords if larger is invalid due to alignment.  */
  344.            || (struct_align == GET_MODE_SIZE (HImode)
  345.            && BIGGEST_ALIGNMENT > GET_MODE_SIZE (HImode))))
  346.     {
  347.       /* It fits in an aligned halfword within the structure,
  348.      and either halfwords are fast
  349.      or the alignment won't let us use anything bigger.  */
  350.       total_bits = GET_MODE_BITSIZE (HImode);
  351.  
  352.       /* Get ref to halfword containing the field.  */
  353.       bitpos += (offset % (total_bits / BITS_PER_UNIT)) * BITS_PER_UNIT;
  354.       offset -= (offset % (total_bits / BITS_PER_UNIT));
  355.       op0 = change_address (op0, HImode, 
  356.                 plus_constant (XEXP (op0, 0), offset));
  357.     }
  358.   else
  359.     {
  360.       /* Get ref to an aligned word containing the field.  */
  361.       /* Adjust BITPOS to be position within a word,
  362.      and OFFSET to be the offset of that word.
  363.      Then alter OP0 to refer to that word.  */
  364.       bitpos += (offset % (BITS_PER_WORD / BITS_PER_UNIT)) * BITS_PER_UNIT;
  365.       offset -= (offset % (BITS_PER_WORD / BITS_PER_UNIT));
  366.       op0 = change_address (op0, SImode,
  367.                 plus_constant (XEXP (op0, 0), offset));
  368.  
  369.       /* Special treatment for a bit field split across two aligned words.  */
  370.       if (bitsize + bitpos > BITS_PER_WORD)
  371.     {
  372.       store_split_bit_field (op0, bitsize, bitpos, value, struct_align);
  373.       return;
  374.     }
  375.     }
  376.  
  377.   mode = GET_MODE (op0);
  378.  
  379.   /* Now MODE is either QImode, HImode or SImode for a MEM as OP0,
  380.      or is SImode for a REG as OP0.  TOTAL_BITS corresponds.
  381.      The bit field is contained entirely within OP0.
  382.      BITPOS is the starting bit number within OP0.
  383.      (OP0's mode may actually be narrower than MODE.)  */
  384.  
  385. #ifdef BYTES_BIG_ENDIAN
  386.   /* BITPOS is the distance between our msb
  387.      and that of the containing datum.
  388.      Convert it to the distance from the lsb.  */
  389.  
  390.   bitpos = total_bits - bitsize - bitpos;
  391. #endif
  392.   /* Now BITPOS is always the distance between our lsb
  393.      and that of OP0.  */
  394.  
  395.   /* Shift VALUE left by BITPOS bits.  If VALUE is not constant,
  396.      we must first convert its mode to MODE.  */
  397.  
  398.   if (GET_CODE (value) == CONST_INT)
  399.     {
  400.       register int v = INTVAL (value);
  401.  
  402.       if (bitsize < HOST_BITS_PER_INT)
  403.     v &= (1 << bitsize) - 1;
  404.  
  405.       if (v == 0)
  406.     all_zero = 1;
  407.       else if (bitsize < HOST_BITS_PER_INT && v == (1 << bitsize) - 1)
  408.     all_one = 1;
  409.  
  410.       value = gen_rtx (CONST_INT, VOIDmode, v << bitpos);
  411.     }
  412.   else
  413.     {
  414.       int must_and = (GET_MODE_BITSIZE (GET_MODE (value)) != bitsize);
  415.  
  416.       if (GET_MODE (value) != mode)
  417.     {
  418.       if ((GET_CODE (value) == REG || GET_CODE (value) == SUBREG)
  419.           && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (value)))
  420.         value = gen_lowpart (mode, value);
  421.       else
  422.         value = convert_to_mode (mode, value, 1);
  423.     }
  424.  
  425.       if (must_and && bitsize < HOST_BITS_PER_INT)
  426.     value = expand_bit_and (mode, value,
  427.                 gen_rtx (CONST_INT, VOIDmode,
  428.                      (1 << bitsize) - 1),
  429.                 0);
  430.       if (bitpos > 0)
  431.     value = expand_shift (LSHIFT_EXPR, mode, value,
  432.                   build_int_2 (bitpos, 0), 0, 1);
  433.     }
  434.  
  435.   /* Now clear the chosen bits in OP0,
  436.      except that if VALUE is -1 we need not bother.  */
  437.  
  438.   subtarget = op0;
  439.  
  440.   if (! all_one)
  441.     subtarget = expand_bit_and (mode, op0,
  442.                 gen_rtx (CONST_INT, VOIDmode, 
  443.                      (~ (((unsigned) ~0
  444.                           >> (HOST_BITS_PER_INT - bitsize))
  445.                          << bitpos))
  446.                      & ((GET_MODE_BITSIZE (mode)
  447.                          == HOST_BITS_PER_INT)
  448.                         ? -1
  449.                         : ((1 << GET_MODE_BITSIZE (mode)) - 1))),
  450.                 subtarget);
  451.  
  452.   /* Now logical-or VALUE into OP0, unless it is zero.  */
  453.  
  454.   if (! all_zero)
  455.     subtarget = expand_binop (mode, ior_optab, subtarget, value,
  456.                   op0, 1, OPTAB_LIB_WIDEN);
  457.   if (op0 != subtarget)
  458.     emit_move_insn (op0, subtarget);
  459. }
  460.  
  461. /* Store a bit field that is split across two words.
  462.  
  463.    OP0 is the REG, SUBREG or MEM rtx for the first of the two words.
  464.    BITSIZE is the field width; BITPOS the position of its first bit
  465.    (within the word).
  466.    VALUE is the value to store.  */
  467.  
  468. static void
  469. store_split_bit_field (op0, bitsize, bitpos, value, align)
  470.      rtx op0;
  471.      int bitsize, bitpos;
  472.      rtx value;
  473.      int align;
  474. {
  475.   /* BITSIZE_1 is size of the part in the first word.  */
  476.   int bitsize_1 = BITS_PER_WORD - bitpos;
  477.   /* BITSIZE_2 is size of the rest (in the following word).  */
  478.   int bitsize_2 = bitsize - bitsize_1;
  479.   rtx part1, part2;
  480.  
  481.   /* Alignment of VALUE, after conversion.  */
  482.   int valalign = GET_MODE_SIZE (SImode);
  483.  
  484.   if (GET_MODE (value) != VOIDmode)
  485.     value = convert_to_mode (SImode, value, 1);
  486.   if (CONSTANT_P (value) && GET_CODE (value) != CONST_INT)
  487.     value = copy_to_reg (value);
  488.  
  489.   /* Split the value into two parts:
  490.      PART1 gets that which goes in the first word; PART2 the other.  */
  491. #ifdef BYTES_BIG_ENDIAN
  492.   /* PART1 gets the more significant part.  */
  493.   if (GET_CODE (value) == CONST_INT)
  494.     {
  495.       part1 = gen_rtx (CONST_INT, VOIDmode,
  496.                (unsigned) (INTVAL (value)) >> bitsize_2);
  497.       part2 = gen_rtx (CONST_INT, VOIDmode,
  498.                (unsigned) (INTVAL (value)) & ((1 << bitsize_2) - 1));
  499.     }
  500.   else
  501.     {
  502.       part1 = extract_fixed_bit_field (SImode, value, 0, bitsize_1,
  503.                        BITS_PER_WORD - bitsize, 0, 1, valalign);
  504.       part2 = extract_fixed_bit_field (SImode, value, 0, bitsize_2,
  505.                        BITS_PER_WORD - bitsize_2, 0, 1, valalign);
  506.     }
  507. #else
  508.   /* PART1 gets the less significant part.  */
  509.   if (GET_CODE (value) == CONST_INT)
  510.     {
  511.       part1 = gen_rtx (CONST_INT, VOIDmode,
  512.                (unsigned) (INTVAL (value)) & ((1 << bitsize_1) - 1));
  513.       part2 = gen_rtx (CONST_INT, VOIDmode,
  514.                (unsigned) (INTVAL (value)) >> bitsize_1);
  515.     }
  516.   else
  517.     {
  518.       part1 = extract_fixed_bit_field (SImode, value, 0, bitsize_1, 0,
  519.                        0, 1, valalign);
  520.       part2 = extract_fixed_bit_field (SImode, value, 0, bitsize_2,
  521.                        bitsize_1, 0, 1, valalign);
  522.     }
  523. #endif
  524.  
  525.   /* Store PART1 into the first word.  */
  526.   store_fixed_bit_field (op0, 0, bitsize_1, bitpos, part1, align);
  527.  
  528.   /* Offset op0 to get to the following word.  */
  529.   if (GET_CODE (op0) == MEM)
  530.     op0 = change_address (op0, SImode,
  531.               plus_constant (XEXP (op0, 0), UNITS_PER_WORD));
  532.   else if (GET_CODE (op0) == REG)
  533.     op0 = gen_rtx (SUBREG, SImode, op0, 1);
  534.   else if (GET_CODE (op0) == SUBREG)
  535.     op0 = gen_rtx (SUBREG, SImode, SUBREG_REG (op0), SUBREG_WORD (op0) + 1);
  536.  
  537.   /* Store PART2 into the second word.  */
  538.   store_fixed_bit_field (op0, 0, bitsize_2, 0, part2, align);
  539. }
  540.  
  541. /* Generate code to extract a byte-field from STR_RTX
  542.    containing BITSIZE bits, starting at BITNUM,
  543.    and put it in TARGET if possible (if TARGET is nonzero).
  544.    Regardless of TARGET, we return the rtx for where the value is placed.
  545.    It may be a QUEUED.
  546.  
  547.    STR_RTX is the structure containing the byte (a REG or MEM).
  548.    UNSIGNEDP is nonzero if this is an unsigned bit field.
  549.    MODE is the natural mode of the field value once extracted.
  550.    TMODE is the mode the caller would like the value to have;
  551.    but the value may be returned with type MODE instead.
  552.  
  553.    ALIGN is the alignment that STR_RTX is known to have, measured in bytes.
  554.  
  555.    If a TARGET is specified and we can store in it at no extra cost,
  556.    we do so, and return TARGET.
  557.    Otherwise, we return a REG of mode TMODE or MODE, with TMODE preferred
  558.    if they are equally easy.  */
  559.  
  560. rtx
  561. extract_bit_field (str_rtx, bitsize, bitnum, unsignedp,
  562.            target, mode, tmode, align)
  563.      rtx str_rtx;
  564.      register int bitsize;
  565.      int bitnum;
  566.      int unsignedp;
  567.      rtx target;
  568.      enum machine_mode mode, tmode;
  569.      int align;
  570. {
  571.   int unit = (GET_CODE (str_rtx) == MEM) ? BITS_PER_UNIT : BITS_PER_WORD;
  572.   register int offset = bitnum / unit;
  573.   register int bitpos = bitnum % unit;
  574.   register rtx op0 = str_rtx;
  575.   rtx spec_target = target;
  576.   rtx bitsize_rtx, bitpos_rtx;
  577.   rtx spec_target_subreg = 0;
  578.  
  579.   if (tmode == VOIDmode)
  580.     tmode = mode;
  581.  
  582.   while (GET_CODE (op0) == SUBREG)
  583.     {
  584.       offset += SUBREG_WORD (op0);
  585.       op0 = SUBREG_REG (op0);
  586.     }
  587.   
  588. #ifdef BYTES_BIG_ENDIAN
  589.   /* If OP0 is a register, BITPOS must count within a word.
  590.      But as we have it, it counts within whatever size OP0 now has.
  591.      On a bigendian machine, these are not the same, so convert.  */
  592.   if (GET_CODE (op0) != MEM && unit > GET_MODE_BITSIZE (GET_MODE (op0)))
  593.     bitpos += unit - GET_MODE_BITSIZE (GET_MODE (op0));
  594. #endif
  595.  
  596.   /* Extracting a full-word or multi-word value
  597.      from a structure in a register.
  598.      This can be done with just SUBREG.
  599.      So too extracting a subword value in
  600.      the least significant part of the register.  */
  601.  
  602.   if (GET_CODE (op0) == REG
  603.       && (bitsize >= BITS_PER_WORD
  604.       || ((bitsize == GET_MODE_BITSIZE (mode)
  605.            || bitsize == GET_MODE_BITSIZE (QImode)
  606.            || bitsize == GET_MODE_BITSIZE (HImode))
  607. #ifdef BYTES_BIG_ENDIAN
  608.           && bitpos + bitsize == BITS_PER_WORD
  609. #else
  610.           && bitpos == 0
  611. #endif
  612.           )))
  613.     {
  614.       enum machine_mode mode1 = mode;
  615.  
  616.       if (bitsize == GET_MODE_BITSIZE (QImode))
  617.     mode1 = QImode;
  618.       if (bitsize == GET_MODE_BITSIZE (HImode))
  619.     mode1 = HImode;
  620.  
  621.       if (mode1 != GET_MODE (op0))
  622.     op0 = gen_rtx (SUBREG, mode1, op0, offset);
  623.  
  624.       if (mode1 != mode)
  625.     return convert_to_mode (tmode, op0, unsignedp);
  626.       return op0;
  627.     }
  628.   
  629.   /* From here on we know the desired field is smaller than a word
  630.      so we can assume it is an integer.  So we can safely extract it as one
  631.      size of integer, if necessary, and then truncate or extend
  632.      to the size that is wanted.  */
  633.  
  634.   /* OFFSET is the number of words or bytes (UNIT says which)
  635.      from STR_RTX to the first word or byte containing part of the field.  */
  636.  
  637.   if (GET_CODE (op0) == REG)
  638.     {
  639.       if (offset != 0
  640.       || GET_MODE_SIZE (GET_MODE (op0)) > GET_MODE_SIZE (SImode))
  641.     op0 = gen_rtx (SUBREG, SImode, op0, offset);
  642.       offset = 0;
  643.     }
  644.   else
  645.     {
  646.       op0 = protect_from_queue (str_rtx, 1);
  647.     }
  648.  
  649.   /* Now OFFSET is nonzero only for memory operands.  */
  650.  
  651.   if (unsignedp)
  652.     {
  653. #ifdef HAVE_extzv
  654.       if (HAVE_extzv)
  655.     {
  656.       int xbitpos = bitpos, xoffset = offset;
  657.       rtx last = get_last_insn();
  658.       rtx xop0 = op0;
  659.       rtx xtarget = target;
  660.       rtx xspec_target = spec_target;
  661.       rtx xspec_target_subreg = spec_target_subreg;
  662.       rtx pat;
  663.  
  664.       /* Get ref to first byte containing part of the field.  */
  665.       if (GET_CODE (xop0) == MEM)
  666.         {
  667.           if (! ((*insn_operand_predicate[(int) CODE_FOR_extzv][1])
  668.              (xop0, GET_MODE (xop0))))
  669.         {
  670.           enum machine_mode bestmode = VOIDmode, trymode;
  671.           int maxsize = GET_MODE_SIZE (insn_operand_mode[(int) CODE_FOR_extzv][1]);
  672.  
  673.           /* Find biggest machine mode we can safely use
  674.              to fetch from this structure.
  675.              But don't use a bigger mode than the insn wants.  */
  676.           for (trymode = QImode;
  677.                trymode && GET_MODE_SIZE (trymode) <= maxsize;
  678.                trymode = GET_MODE_WIDER_MODE (trymode))
  679.             if (GET_MODE_SIZE (trymode) <= align)
  680.               bestmode = trymode;
  681.           if (! bestmode)
  682.             abort ();
  683.           unit = GET_MODE_BITSIZE (bestmode);
  684.  
  685.           /* Compute offset as multiple of this unit,
  686.              counting in bytes.  */
  687.           xoffset = (bitnum / unit) * GET_MODE_SIZE (bestmode);
  688.           xbitpos = bitnum % unit;
  689.           xop0 = change_address (xop0, bestmode,
  690.                      plus_constant (XEXP (xop0, 0),
  691.                             xoffset));
  692.           /* Fetch it to a register in that size.  */
  693.           xop0 = force_reg (bestmode, xop0);
  694.  
  695.           /* Now ref the register in the mode extzv wants.  */
  696.           if (bestmode != insn_operand_mode[(int) CODE_FOR_extzv][1])
  697.             xop0 = gen_rtx (SUBREG, insn_operand_mode[(int) CODE_FOR_extzv][1],
  698.                     xop0, 0);
  699. #ifdef BITS_BIG_ENDIAN
  700.           if (GET_MODE_BITSIZE (GET_MODE (xop0)) > unit)
  701.             xbitpos += GET_MODE_BITSIZE (GET_MODE (xop0)) - unit;
  702. #endif
  703.         }
  704.           else
  705.         xop0 = change_address (xop0, QImode,
  706.                        plus_constant (XEXP (xop0, 0), xoffset));
  707.         }
  708.  
  709.       /* If op0 is a register, we need it in SImode
  710.          to make it acceptable to the format of extzv.  */
  711.       if (GET_CODE (xop0) == SUBREG && GET_MODE (xop0) != SImode)
  712.         abort ();
  713.       if (GET_CODE (xop0) == REG && GET_MODE (xop0) != SImode)
  714.         xop0 = gen_rtx (SUBREG, SImode, xop0, 0);
  715.  
  716.       if (xtarget == 0
  717.           || (flag_force_mem && GET_CODE (xtarget) == MEM))
  718.         xtarget = xspec_target = gen_reg_rtx (tmode);
  719.  
  720.       if (GET_MODE (xtarget) != SImode)
  721.         {
  722.           if (GET_CODE (xtarget) == REG)
  723.         xspec_target_subreg = xtarget = gen_lowpart (SImode, xtarget);
  724.           else
  725.         xtarget = gen_reg_rtx (SImode);
  726.         }
  727.  
  728.       /* If this machine's extzv insists on a register target,
  729.          make sure we have one.  */
  730.       if (! (*insn_operand_predicate[(int) CODE_FOR_extzv][0]) (xtarget, SImode))
  731.         xtarget = gen_reg_rtx (SImode);
  732.  
  733.       /* On big-endian machines, we count bits from the most significant.
  734.          If the bit field insn does not, we must invert.  */
  735. #if defined (BITS_BIG_ENDIAN) != defined (BYTES_BIG_ENDIAN)
  736.       xbitpos = unit - 1 - xbitpos;
  737. #endif
  738.  
  739.       bitsize_rtx = gen_rtx (CONST_INT, VOIDmode, bitsize);
  740.       bitpos_rtx = gen_rtx (CONST_INT, VOIDmode, xbitpos);
  741.  
  742.       pat = gen_extzv (protect_from_queue (xtarget, 1),
  743.                xop0, bitsize_rtx, bitpos_rtx);
  744.       if (pat)
  745.         {
  746.           emit_insn (pat);
  747.           target = xtarget;
  748.           spec_target = xspec_target;
  749.           spec_target_subreg = xspec_target_subreg;
  750.         }
  751.       else
  752.         {
  753.           delete_insns_since (last);
  754.           target = extract_fixed_bit_field (tmode, op0, offset, bitsize,
  755.                         bitpos, target, 1, align);
  756.         }
  757.     }
  758.       else
  759. #endif
  760.     target = extract_fixed_bit_field (tmode, op0, offset, bitsize, bitpos,
  761.                       target, 1, align);
  762.     }
  763.   else
  764.     {
  765. #ifdef HAVE_extv
  766.       if (HAVE_extv)
  767.     {
  768.       int xbitpos = bitpos, xoffset = offset;
  769.       rtx last = get_last_insn();
  770.       rtx xop0 = op0, xtarget = target;
  771.       rtx xspec_target = spec_target;
  772.       rtx xspec_target_subreg = spec_target_subreg;
  773.       rtx pat;
  774.  
  775.       /* Get ref to first byte containing part of the field.  */
  776.       if (GET_CODE (xop0) == MEM)
  777.         {
  778.           if (! ((*insn_operand_predicate[(int) CODE_FOR_extv][1])
  779.              (xop0, GET_MODE (xop0))))
  780.         {
  781.           enum machine_mode bestmode = VOIDmode, trymode;
  782.           int maxsize = GET_MODE_SIZE (insn_operand_mode[(int) CODE_FOR_extzv][1]);
  783.  
  784.           /* Find biggest machine mode we can safely use
  785.              to fetch from this structure.
  786.              But don't use a bigger mode than the insn wants.  */
  787.           for (trymode = QImode;
  788.                trymode && GET_MODE_SIZE (trymode) <= maxsize;
  789.                trymode = GET_MODE_WIDER_MODE (trymode))
  790.             if (GET_MODE_SIZE (trymode) <= align)
  791.               bestmode = trymode;
  792.           if (! bestmode)
  793.             abort ();
  794.           unit = GET_MODE_BITSIZE (bestmode);
  795.  
  796.           /* Compute offset as multiple of this unit,
  797.              counting in bytes.  */
  798.           xoffset = (bitnum / unit) * GET_MODE_SIZE (bestmode);
  799.           xbitpos = bitnum % unit;
  800.           xop0 = change_address (xop0, bestmode,
  801.                      plus_constant (XEXP (xop0, 0),
  802.                             xoffset));
  803.           /* Fetch it to a register in that size.  */
  804.           xop0 = force_reg (bestmode, xop0);
  805.  
  806.           /* Now ref the register in the mode extv wants.  */
  807.           if (bestmode != insn_operand_mode[(int) CODE_FOR_extv][1])
  808.             xop0 = gen_rtx (SUBREG, insn_operand_mode[(int) CODE_FOR_extv][1],
  809.                     xop0, 0);
  810. #ifdef BITS_BIG_ENDIAN
  811.           if (GET_MODE_BITSIZE (GET_MODE (xop0)) > unit)
  812.             xbitpos += GET_MODE_BITSIZE (GET_MODE (xop0)) - unit;
  813. #endif
  814.         }
  815.           else
  816.         xop0 = change_address (xop0, QImode,
  817.                        plus_constant (XEXP (xop0, 0), xoffset));
  818.         }
  819.  
  820.       /* If op0 is a register, we need it in SImode
  821.          to make it acceptable to the format of extv.  */
  822.       if (GET_CODE (xop0) == SUBREG && GET_MODE (xop0) != SImode)
  823.         abort ();
  824.       if (GET_CODE (xop0) == REG && GET_MODE (xop0) != SImode)
  825.         xop0 = gen_rtx (SUBREG, SImode, xop0, 0);
  826.  
  827.       if (xtarget == 0
  828.           || (flag_force_mem && GET_CODE (xtarget) == MEM))
  829.         xtarget = xspec_target = gen_reg_rtx (tmode);
  830.  
  831.       if (GET_MODE (xtarget) != SImode)
  832.         {
  833.           if (GET_CODE (xtarget) == REG)
  834.         xspec_target_subreg = xtarget = gen_lowpart (SImode, xtarget);
  835.           else
  836.         xtarget = gen_reg_rtx (SImode);
  837.         }
  838.  
  839.       /* If this machine's extv insists on a register target,
  840.          make sure we have one.  */
  841.       if (! (*insn_operand_predicate[(int) CODE_FOR_extv][0]) (xtarget, SImode))
  842.         xtarget = gen_reg_rtx (SImode);
  843.  
  844.       /* On big-endian machines, we count bits from the most significant.
  845.          If the bit field insn does not, we must invert.  */
  846. #if defined (BITS_BIG_ENDIAN) != defined (BYTES_BIG_ENDIAN)
  847.       xbitpos = unit - 1 - xbitpos;
  848. #endif
  849.  
  850.       bitsize_rtx = gen_rtx (CONST_INT, VOIDmode, bitsize);
  851.       bitpos_rtx = gen_rtx (CONST_INT, VOIDmode, xbitpos);
  852.  
  853.       pat = gen_extv (protect_from_queue (xtarget, 1),
  854.               xop0, bitsize_rtx, bitpos_rtx);
  855.       if (pat)
  856.         {
  857.           emit_insn (pat);
  858.           target = xtarget;
  859.           spec_target = xspec_target;
  860.           spec_target_subreg = xspec_target_subreg;
  861.         }
  862.       else
  863.         {
  864.           delete_insns_since (last);
  865.           target = extract_fixed_bit_field (tmode, op0, offset, bitsize,
  866.                         bitpos, target, 0, align);
  867.         }
  868.     } 
  869.       else
  870. #endif
  871.     target = extract_fixed_bit_field (tmode, op0, offset, bitsize, bitpos,
  872.                       target, 0, align);
  873.     }
  874.   if (target == spec_target)
  875.     return target;
  876.   if (target == spec_target_subreg)
  877.     return spec_target;
  878.   if (GET_MODE (target) != tmode && GET_MODE (target) != mode)
  879.     return convert_to_mode (tmode, target, unsignedp);
  880.   return target;
  881. }
  882.  
  883. /* Extract a bit field using shifts and boolean operations
  884.    Returns an rtx to represent the value.
  885.    OP0 addresses a register (word) or memory (byte).
  886.    BITPOS says which bit within the word or byte the bit field starts in.
  887.    OFFSET says how many bytes farther the bit field starts;
  888.     it is 0 if OP0 is a register.
  889.    BITSIZE says how many bits long the bit field is.
  890.     (If OP0 is a register, it may be narrower than SImode,
  891.      but BITPOS still counts within a full word,
  892.      which is significant on bigendian machines.)
  893.  
  894.    UNSIGNEDP is nonzero for an unsigned bit field (don't sign-extend value).
  895.    If TARGET is nonzero, attempts to store the value there
  896.    and return TARGET, but this is not guaranteed.
  897.    If TARGET is not used, create a pseudo-reg of mode TMODE for the value.
  898.  
  899.    ALIGN is the alignment that STR_RTX is known to have, measured in bytes.  */
  900.  
  901. static rtx
  902. extract_fixed_bit_field (tmode, op0, offset, bitsize, bitpos,
  903.              target, unsignedp, align)
  904.      enum machine_mode tmode;
  905.      register rtx op0, target;
  906.      register int offset, bitsize, bitpos;
  907.      int unsignedp;
  908.      int align;
  909. {
  910.   int total_bits = BITS_PER_WORD;
  911.   enum machine_mode mode;
  912.  
  913.   if (GET_CODE (op0) == SUBREG || GET_CODE (op0) == REG)
  914.     {
  915.       /* Special treatment for a bit field split across two registers.  */
  916.       if (bitsize + bitpos > BITS_PER_WORD)
  917.     return extract_split_bit_field (op0, bitsize, bitpos,
  918.                     unsignedp, align);
  919.     }
  920.   else if (bitsize + bitpos <= BITS_PER_UNIT
  921.        && (! SLOW_BYTE_ACCESS
  922.            || (align == 1
  923.            && BIGGEST_ALIGNMENT > 1)))
  924.     {
  925.       /* It fits in one byte, and either bytes are fast
  926.      or the alignment won't let us use anything bigger.  */
  927.       total_bits = BITS_PER_UNIT;
  928.       op0 = change_address (op0, QImode, 
  929.                 plus_constant (XEXP (op0, 0), offset));
  930.     }
  931.   else if ((bitsize + bitpos + (offset % GET_MODE_SIZE (HImode)) * BITS_PER_UNIT
  932.         <= GET_MODE_BITSIZE (HImode))
  933.        /* If halfwords are fast, use them whenever valid.  */
  934.        && (! SLOW_BYTE_ACCESS
  935.            /* Use halfwords if larger is invalid due to alignment.  */
  936.            || (align == GET_MODE_SIZE (HImode)
  937.            && BIGGEST_ALIGNMENT > GET_MODE_SIZE (HImode))))
  938.     {
  939.       /* It fits in an aligned halfword, and either halfwords are fast
  940.      or the alignment won't let us use anything bigger.  */
  941.       total_bits = GET_MODE_BITSIZE (HImode);
  942.  
  943.       /* Get ref to halfword containing the field.  */
  944.       bitpos += (offset % (total_bits / BITS_PER_UNIT)) * BITS_PER_UNIT;
  945.       offset -= (offset % (total_bits / BITS_PER_UNIT));
  946.       op0 = change_address (op0, HImode, 
  947.                 plus_constant (XEXP (op0, 0), offset));
  948.     }
  949.   else
  950.     {
  951.       /* Get ref to word containing the field.  */
  952.       /* Adjust BITPOS to be position within a word,
  953.      and OFFSET to be the offset of that word.  */
  954.       bitpos += (offset % (BITS_PER_WORD / BITS_PER_UNIT)) * BITS_PER_UNIT;
  955.       offset -= (offset % (BITS_PER_WORD / BITS_PER_UNIT));
  956.       op0 = change_address (op0, SImode,
  957.                 plus_constant (XEXP (op0, 0), offset));
  958.  
  959.       /* Special treatment for a bit field split across two words.  */
  960.       if (bitsize + bitpos > BITS_PER_WORD)
  961.     return extract_split_bit_field (op0, bitsize, bitpos,
  962.                     unsignedp, align);
  963.     }
  964.  
  965.   mode = GET_MODE (op0);
  966.  
  967. #ifdef BYTES_BIG_ENDIAN
  968.   /* BITPOS is the distance between our msb and that of OP0.
  969.      Convert it to the distance from the lsb.  */
  970.  
  971.   bitpos = total_bits - bitsize - bitpos;
  972. #endif
  973.   /* Now BITPOS is always the distance between the field's lsb and that of OP0.
  974.      We have reduced the big-endian case to the little-endian case.  */
  975.  
  976.   if (unsignedp)
  977.     {
  978.       if (bitpos)
  979.     {
  980.       /* If the field does not already start at the lsb,
  981.          shift it so it does.  */
  982.       tree amount = build_int_2 (bitpos, 0);
  983.       /* Maybe propagate the target for the shift.  */
  984.       /* But not if we will return it--could confuse integrate.c.  */
  985.       rtx subtarget = (target != 0 && GET_CODE (target) == REG
  986.                && !REG_FUNCTION_VALUE_P (target)
  987.                ? target : 0);
  988.       if (tmode != mode) subtarget = 0;
  989.       op0 = expand_shift (RSHIFT_EXPR, mode, op0, amount, subtarget, 1);
  990.     }
  991.       /* Convert the value to the desired mode.  */
  992.       if (mode != tmode)
  993.     op0 = convert_to_mode (tmode, op0, 1);
  994.  
  995.       /* Unless the msb of the field used to be the msb when we shifted,
  996.      mask out the upper bits.  */
  997.  
  998.       if ((GET_MODE_BITSIZE (mode) != bitpos + bitsize
  999. #if 0
  1000. #ifdef SLOW_ZERO_EXTEND
  1001.        /* Always generate an `and' if
  1002.           we just zero-extended op0 and SLOW_ZERO_EXTEND, since it
  1003.           will combine fruitfully with the zero-extend. */
  1004.        || tmode != mode
  1005. #endif
  1006. #endif
  1007.        )
  1008.       && bitsize < HOST_BITS_PER_INT)
  1009.     return expand_bit_and (GET_MODE (op0), op0,
  1010.                    gen_rtx (CONST_INT, VOIDmode, (1 << bitsize) - 1),
  1011.                    target);
  1012.       return op0;
  1013.     }
  1014.  
  1015.   /* To extract a signed bit-field, first shift its msb to the msb of the word,
  1016.      then arithmetic-shift its lsb to the lsb of the word.  */
  1017.   op0 = force_reg (mode, op0);
  1018.   if (mode != tmode)
  1019.     target = 0;
  1020.   if (GET_MODE_BITSIZE (QImode) < GET_MODE_BITSIZE (mode)
  1021.       && GET_MODE_BITSIZE (QImode) >= bitsize + bitpos)
  1022.     mode = QImode, op0 = convert_to_mode (QImode, op0, 0);
  1023.   if (GET_MODE_BITSIZE (HImode) < GET_MODE_BITSIZE (mode)
  1024.       && GET_MODE_BITSIZE (HImode) >= bitsize + bitpos)
  1025.     mode = HImode, op0 = convert_to_mode (HImode, op0, 0);
  1026.   if (GET_MODE_BITSIZE (mode) != (bitsize + bitpos))
  1027.     {
  1028.       tree amount = build_int_2 (GET_MODE_BITSIZE (mode) - (bitsize + bitpos), 0);
  1029.       /* Maybe propagate the target for the shift.  */
  1030.       /* But not if we will return the result--could confuse integrate.c.  */
  1031.       rtx subtarget = (target != 0 && GET_CODE (target) == REG
  1032.                && ! REG_FUNCTION_VALUE_P (target)
  1033.                ? target : 0);
  1034.       op0 = expand_shift (LSHIFT_EXPR, mode, op0, amount, subtarget, 1);
  1035.     }
  1036.  
  1037.   return expand_shift (RSHIFT_EXPR, mode, op0,
  1038.                build_int_2 (GET_MODE_BITSIZE (mode) - bitsize, 0), 
  1039.                target, 0);
  1040. }
  1041.  
  1042. /* Extract a bit field that is split across two words
  1043.    and return an RTX for the result.
  1044.  
  1045.    OP0 is the REG, SUBREG or MEM rtx for the first of the two words.
  1046.    BITSIZE is the field width; BITPOS, position of its first bit, in the word.
  1047.    UNSIGNEDP is 1 if should zero-extend the contents; else sign-extend.  */
  1048.  
  1049. static rtx
  1050. extract_split_bit_field (op0, bitsize, bitpos, unsignedp, align)
  1051.      rtx op0;
  1052.      int bitsize, bitpos, unsignedp, align;
  1053. {
  1054.   /* BITSIZE_1 is size of the part in the first word.  */
  1055.   int bitsize_1 = BITS_PER_WORD - bitpos;
  1056.   /* BITSIZE_2 is size of the rest (in the following word).  */
  1057.   int bitsize_2 = bitsize - bitsize_1;
  1058.   rtx part1, part2, result;
  1059.  
  1060.   /* Get the part of the bit field from the first word.  */
  1061.   part1 = extract_fixed_bit_field (SImode, op0, 0, bitsize_1, bitpos,
  1062.                    0, 1, align);
  1063.  
  1064.   /* Offset op0 by 1 word to get to the following one.  */
  1065.   if (GET_CODE (op0) == MEM)
  1066.     op0 = change_address (op0, SImode,
  1067.               plus_constant (XEXP (op0, 0), UNITS_PER_WORD));
  1068.   else if (GET_CODE (op0) == REG)
  1069.     op0 = gen_rtx (SUBREG, SImode, op0, 1);
  1070.   else
  1071.     op0 = gen_rtx (SUBREG, SImode, SUBREG_REG (op0), SUBREG_WORD (op0) + 1);
  1072.  
  1073.   /* Get the part of the bit field from the second word.  */
  1074.   part2 = extract_fixed_bit_field (SImode, op0, 0, bitsize_2, 0, 0, 1, align);
  1075.  
  1076.   /* Shift the more significant part up to fit above the other part.  */
  1077. #ifdef BYTES_BIG_ENDIAN
  1078.   part1 = expand_shift (LSHIFT_EXPR, SImode, part1,
  1079.             build_int_2 (bitsize_2, 0), 0, 1);
  1080. #else
  1081.   part2 = expand_shift (LSHIFT_EXPR, SImode, part2,
  1082.             build_int_2 (bitsize_1, 0), 0, 1);
  1083. #endif
  1084.  
  1085.   /* Combine the two parts with bitwise or.  This works
  1086.      because we extracted both parts as unsigned bit fields.  */
  1087.   result = expand_binop (SImode, ior_optab, part1, part2, 0, 1,
  1088.              OPTAB_LIB_WIDEN);
  1089.  
  1090.   /* Unsigned bit field: we are done.  */
  1091.   if (unsignedp)
  1092.     return result;
  1093.   /* Signed bit field: sign-extend with two arithmetic shifts.  */
  1094.   result = expand_shift (LSHIFT_EXPR, SImode, result,
  1095.              build_int_2 (BITS_PER_WORD - bitsize, 0), 0, 0);
  1096.   return expand_shift (RSHIFT_EXPR, SImode, result,
  1097.                build_int_2 (BITS_PER_WORD - bitsize, 0), 0, 0);
  1098. }
  1099.  
  1100. /* Add INC into TARGET.  */
  1101.  
  1102. void
  1103. expand_inc (target, inc)
  1104.      rtx target, inc;
  1105. {
  1106.   rtx value = expand_binop (GET_MODE (target), add_optab,
  1107.                 target, inc,
  1108.                 target, 0, OPTAB_LIB_WIDEN);
  1109.   if (value != target)
  1110.     emit_move_insn (target, value);
  1111. }
  1112.  
  1113. /* Subtract INC from TARGET.  */
  1114.  
  1115. void
  1116. expand_dec (target, dec)
  1117.      rtx target, dec;
  1118. {
  1119.   rtx value = expand_binop (GET_MODE (target), sub_optab,
  1120.                 target, dec,
  1121.                 target, 0, OPTAB_LIB_WIDEN);
  1122.   if (value != target)
  1123.     emit_move_insn (target, value);
  1124. }
  1125.  
  1126. /* Output a shift instruction for expression code CODE,
  1127.    with SHIFTED being the rtx for the value to shift,
  1128.    and AMOUNT the tree for the amount to shift by.
  1129.    Store the result in the rtx TARGET, if that is convenient.
  1130.    If UNSIGNEDP is nonzero, do a logical shift; otherwise, arithmetic.
  1131.    Return the rtx for where the value is.  */
  1132.  
  1133. /* Pastel, for shifts, converts shift count to SImode here
  1134.    independent of the mode being shifted.
  1135.    Should that be done in an earlier pass?
  1136.    It turns out not to matter for C.  */
  1137.  
  1138. rtx
  1139. expand_shift (code, mode, shifted, amount, target, unsignedp)
  1140.      enum tree_code code;
  1141.      register enum machine_mode mode;
  1142.      rtx shifted;
  1143.      tree amount;
  1144.      register rtx target;
  1145.      int unsignedp;
  1146. {
  1147.   register rtx op1, temp = 0;
  1148.   register int left = (code == LSHIFT_EXPR || code == LROTATE_EXPR);
  1149.   int try;
  1150.   int rotate = code == LROTATE_EXPR || code == RROTATE_EXPR;
  1151.   rtx last;
  1152.  
  1153.   /* Previously detected shift-counts computed by NEGATE_EXPR
  1154.      and shifted in the other direction; but that does not work
  1155.      on all machines.  */
  1156.  
  1157.   op1 = expand_expr (amount, 0, VOIDmode, 0);
  1158.  
  1159.   last = get_last_insn ();
  1160.  
  1161.   for (try = 0; temp == 0 && try < 3; try++)
  1162.     {
  1163.       enum optab_methods methods;
  1164.       delete_insns_since (last);
  1165.  
  1166.       if (try == 0)
  1167.     methods = OPTAB_DIRECT;
  1168.       else if (try == 1)
  1169.     methods = OPTAB_WIDEN;
  1170.       else
  1171.     methods = OPTAB_LIB_WIDEN;
  1172.  
  1173.       if (rotate)
  1174.     {
  1175.       /* Widening does not work for rotation.  */
  1176.       if (methods != OPTAB_DIRECT)
  1177.         methods = OPTAB_LIB;
  1178.  
  1179.       temp = expand_binop (mode,
  1180.                    left ? rotl_optab : rotr_optab,
  1181.                    shifted, op1, target, -1, methods);
  1182.     }
  1183.       else if (unsignedp)
  1184.     {
  1185.       temp = expand_binop (mode,
  1186.                    left ? lshl_optab : lshr_optab,
  1187.                    shifted, op1, target, unsignedp, methods);
  1188.       if (temp == 0 && left)
  1189.         temp = expand_binop (mode, ashl_optab,
  1190.                  shifted, op1, target, unsignedp, methods);
  1191.       if (temp != 0)
  1192.         return temp;
  1193.     }
  1194.       /* Do arithmetic shifts.
  1195.      Also, if we are going to widen the operand, we can just as well
  1196.      use an arithmetic right-shift instead of a logical one.  */
  1197.       if (! rotate && (! unsignedp || (! left && methods == OPTAB_WIDEN)))
  1198.     {
  1199.       enum optab_methods methods1 = methods;
  1200.  
  1201.       /* If trying to widen a log shift to an arithmetic shift,
  1202.          don't accept an arithmetic shift of the same size.  */
  1203.       if (unsignedp)
  1204.         methods1 = OPTAB_MUST_WIDEN;
  1205.  
  1206.       /* Arithmetic shift */
  1207.  
  1208.       temp = expand_binop (mode,
  1209.                    left ? ashl_optab : ashr_optab,
  1210.                    shifted, op1, target, unsignedp, methods1);
  1211.       if (temp != 0)
  1212.         return temp;
  1213.     }
  1214.  
  1215.       if (unsignedp)
  1216.     {
  1217.       /* No logical shift insn in either direction =>
  1218.          try a bit-field extract instruction if we have one.  */
  1219. #ifdef HAVE_extzv
  1220. #ifndef BITS_BIG_ENDIAN
  1221.       if (HAVE_extzv && !left
  1222.           && ((methods == OPTAB_DIRECT && mode == SImode)
  1223.           || (methods == OPTAB_WIDEN
  1224.               && GET_MODE_SIZE (mode) < GET_MODE_SIZE (SImode))))
  1225.         {
  1226.           rtx shifted1 = convert_to_mode (SImode, shifted, 1);
  1227.           rtx target1 = target;
  1228.  
  1229.           /* If -fforce-mem, don't let the operand be in memory.  */
  1230.           if (flag_force_mem && GET_CODE (shifted1) == MEM)
  1231.         shifted1 = force_not_mem (shifted1);
  1232.  
  1233.           /* If this machine's extzv insists on a register for
  1234.          operand 1, arrange for that.  */
  1235.           if (! ((*insn_operand_predicate[(int) CODE_FOR_extzv][1])
  1236.              (shifted1, SImode)))
  1237.         shifted1 = force_reg (SImode, shifted1);
  1238.  
  1239.           /* If we don't have or cannot use a suggested target,
  1240.          make a place for the result, in the proper mode.  */
  1241.           if (methods == OPTAB_WIDEN || target1 == 0
  1242.           || ! ((*insn_operand_predicate[(int) CODE_FOR_extzv][0])
  1243.             (target1, SImode)))
  1244.         target1 = gen_reg_rtx (SImode);
  1245.  
  1246.           op1 = convert_to_mode (SImode, op1, 0);
  1247.  
  1248.           /* If this machine's extzv insists on a register for
  1249.          operand 3, arrange for that.  */
  1250.           if (! ((*insn_operand_predicate[(int) CODE_FOR_extzv][3])
  1251.              (op1, SImode)))
  1252.         op1 = force_reg (SImode, op1);
  1253.  
  1254.           op1 = protect_from_queue (op1, 1);
  1255.  
  1256.           /* TEMP gets the width of the bit field to extract:
  1257.          wordsize minus # bits to shift by.  */
  1258.           if (GET_CODE (op1) == CONST_INT)
  1259.         temp = gen_rtx (CONST_INT, VOIDmode,
  1260.                 (GET_MODE_BITSIZE (mode) - INTVAL (op1)));
  1261.           else
  1262.         temp = expand_binop (SImode, sub_optab,
  1263.                      gen_rtx (CONST_INT, VOIDmode,
  1264.                           GET_MODE_BITSIZE (mode)),
  1265.                      op1, gen_reg_rtx (SImode),
  1266.                      0, OPTAB_LIB_WIDEN);
  1267.           /* Now extract with width TEMP, omitting OP1 least sig bits.  */
  1268.           emit_insn (gen_extzv (protect_from_queue (target1, 1),
  1269.                     protect_from_queue (shifted1, 0),
  1270.                     temp, op1));
  1271.           return convert_to_mode (mode, target1, 1);
  1272.         }
  1273.       /* Can also do logical shift with signed bit-field extract
  1274.          followed by inserting the bit-field at a different position.
  1275.          That strategy is not yet implemented.  */
  1276. #endif /* not BITS_BIG_ENDIAN */
  1277. #endif /* HAVE_extzv */
  1278.       /* We have failed to generate the logical shift and will abort.  */
  1279.     }
  1280.     }
  1281.   if (temp == 0)
  1282.     abort ();
  1283.   return temp;
  1284. }
  1285.  
  1286. /* Output an instruction or two to bitwise-and OP0 with OP1
  1287.    in mode MODE, with output to TARGET if convenient and TARGET is not zero.
  1288.    Returns where the result is.  */
  1289. /* This function used to do more; now it could be eliminated.  */
  1290.  
  1291. rtx
  1292. expand_bit_and (mode, op0, op1, target)
  1293.      enum machine_mode mode;
  1294.      rtx op0, op1, target;
  1295. {
  1296.   register rtx temp;
  1297.  
  1298.   /* First try to open-code it directly.  */
  1299.   temp = expand_binop (mode, and_optab, op0, op1, target, 1, OPTAB_LIB_WIDEN);
  1300.   if (temp == 0)
  1301.     abort ();
  1302.   return temp;
  1303. }
  1304.  
  1305. /* Perform a multiplication and return an rtx for the result.
  1306.    MODE is mode of value; OP0 and OP1 are what to multiply (rtx's);
  1307.    TARGET is a suggestion for where to store the result (an rtx).
  1308.  
  1309.    We check specially for a constant integer as OP1.
  1310.    If you want this check for OP0 as well, then before calling
  1311.    you should swap the two operands if OP0 would be constant.  */
  1312.  
  1313. rtx
  1314. expand_mult (mode, op0, op1, target, unsignedp)
  1315.      enum machine_mode mode;
  1316.      register rtx op0, op1, target;
  1317.      int unsignedp;
  1318. {
  1319.   /* Don't use the function value register as a target
  1320.      since we have to read it as well as write it,
  1321.      and function-inlining gets confused by this.  */
  1322.   if (target && REG_P (target) && REG_FUNCTION_VALUE_P (target))
  1323.     target = 0;
  1324.  
  1325.   if (GET_CODE (op1) == CONST_INT)
  1326.     {
  1327.       register int foo;
  1328.       int bar;
  1329.       int negate = INTVAL (op1) < 0;
  1330.       int absval = INTVAL (op1) * (negate ? -1 : 1);
  1331.  
  1332.       /* Is multiplier a power of 2, or minus that?  */
  1333.       foo = exact_log2 (absval);
  1334.       if (foo >= 0)
  1335.     {
  1336.       rtx tem;
  1337.       if (foo == 0)
  1338.         tem = op0;
  1339.       else
  1340.         tem = expand_shift (LSHIFT_EXPR, mode, op0,
  1341.                 build_int_2 (foo, 0),
  1342.                 target, 0);
  1343.       return (negate
  1344.           ? expand_unop (mode, neg_optab, tem, target, 0)
  1345.           : tem);
  1346.     }
  1347.       /* Is multiplier a sum of two powers of 2, or minus that?  */
  1348.       bar = floor_log2 (absval);
  1349.       foo = exact_log2 (absval - (1 << bar));
  1350.       if (bar >= 0 && foo >= 0)
  1351.     {
  1352.       rtx tem =
  1353.         force_operand (gen_rtx (PLUS, mode,
  1354.                     expand_shift (LSHIFT_EXPR, mode, op0,
  1355.                              build_int_2 (bar - foo, 0),
  1356.                              0, 0),
  1357.                     op0),
  1358.                ((foo == 0 && ! negate) ? target : 0));
  1359.  
  1360.       if (foo != 0)
  1361.         tem = expand_shift (LSHIFT_EXPR, mode, tem,
  1362.                 build_int_2 (foo, 0),
  1363.                 negate ? 0 : target, 0);
  1364.  
  1365.       return negate ? expand_unop (mode, neg_optab, tem, target, 0) : tem;
  1366.     }
  1367.     }
  1368.   /* This used to use umul_optab if unsigned,
  1369.      but I think that for non-widening multiply there is no difference
  1370.      between signed and unsigned.  */
  1371.   op0 = expand_binop (mode, smul_optab,
  1372.               op0, op1, target, unsignedp, OPTAB_LIB_WIDEN);
  1373.   if (op0 == 0)
  1374.     abort ();
  1375.   return op0;
  1376. }
  1377.  
  1378. /* Emit the code to divide OP0 by OP1, putting the result in TARGET
  1379.    if that is convenient, and returning where the result is.
  1380.    You may request either the quotient or the remainder as the result;
  1381.    specify REM_FLAG nonzero to get the remainder.
  1382.  
  1383.    CODE is the expression code for which kind of division this is;
  1384.    it controls how rounding is done.  MODE is the machine mode to use.
  1385.    UNSIGNEDP nonzero means do unsigned division.  */
  1386.  
  1387. /* ??? For CEIL_MOD_EXPR, can compute incorrect remainder with ANDI
  1388.    and then correct it by or'ing in missing high bits
  1389.    if result of ANDI is nonzero.
  1390.    For ROUND_MOD_EXPR, can use ANDI and then sign-extend the result.
  1391.    This could optimize to a bfexts instruction.
  1392.    But C doesn't use these operations, so their optimizations are
  1393.    left for later.  */
  1394.  
  1395. rtx
  1396. expand_divmod (rem_flag, code, mode, op0, op1, target, unsignedp)
  1397.      int rem_flag;
  1398.      enum tree_code code;
  1399.      enum machine_mode mode;
  1400.      register rtx op0, op1, target;
  1401.      int unsignedp;
  1402. {
  1403.   register rtx temp;
  1404.   int log = -1;
  1405.   int can_clobber_op0;
  1406.   int mod_insn_no_good = 0;
  1407.   rtx adjusted_op0 = op0;
  1408.  
  1409.   /* Don't use the function value register as a target
  1410.      since we have to read it as well as write it,
  1411.      and function-inlining gets confused by this.  */
  1412.   if (target && REG_P (target) && REG_FUNCTION_VALUE_P (target))
  1413.     target = 0;
  1414.  
  1415.   /* Don't clobber an operand while doing a multi-step calculation.  */
  1416.   if (target)
  1417.     if ((rem_flag && (reg_mentioned_p (target, op0)
  1418.               || (GET_CODE (op0) == MEM && GET_CODE (target) == MEM)))
  1419.     || reg_mentioned_p (target, op1)
  1420.     || (GET_CODE (op1) == MEM && GET_CODE (target) == MEM))
  1421.       target = 0;
  1422.  
  1423.   if (target == 0)
  1424.     target = gen_reg_rtx (mode);
  1425.  
  1426.   can_clobber_op0 = (GET_CODE (op0) == REG && op0 == target);
  1427.  
  1428.   if (GET_CODE (op1) == CONST_INT)
  1429.     log = exact_log2 (INTVAL (op1));
  1430.  
  1431.   /* If log is >= 0, we are dividing by 2**log, and will do it by shifting,
  1432.      which is really floor-division.  Otherwise we will really do a divide,
  1433.      and we assume that is trunc-division.
  1434.  
  1435.      We must correct the dividend by adding or subtracting something
  1436.      based on the divisor, in order to do the kind of rounding specified
  1437.      by CODE.  The correction depends on what kind of rounding is actually
  1438.      available, and that depends on whether we will shift or divide.  */
  1439.  
  1440.   switch (code)
  1441.     {
  1442.     case TRUNC_MOD_EXPR:
  1443.     case TRUNC_DIV_EXPR:
  1444.       if (log >= 0 && ! unsignedp)
  1445.     {
  1446.       rtx label = gen_label_rtx ();
  1447.       if (! can_clobber_op0)
  1448.         adjusted_op0 = copy_to_suggested_reg (adjusted_op0, target);
  1449.       emit_cmp_insn (adjusted_op0, const0_rtx, 0, 0, 0);
  1450.       emit_jump_insn (gen_bge (label));
  1451.       expand_inc (adjusted_op0, plus_constant (op1, -1));
  1452.       emit_label (label);
  1453.       mod_insn_no_good = 1;
  1454.     }
  1455.       break;
  1456.  
  1457.     case FLOOR_DIV_EXPR:
  1458.     case FLOOR_MOD_EXPR:
  1459.       if (log < 0 && ! unsignedp)
  1460.     {
  1461.       rtx label = gen_label_rtx ();
  1462.       if (! can_clobber_op0)
  1463.         adjusted_op0 = copy_to_suggested_reg (adjusted_op0, target);
  1464.       emit_cmp_insn (adjusted_op0, const0_rtx, 0, 0, 0);
  1465.       emit_jump_insn (gen_bge (label));
  1466.       expand_dec (adjusted_op0, op1);
  1467.       expand_inc (adjusted_op0, const1_rtx);
  1468.       emit_label (label);
  1469.       mod_insn_no_good = 1;
  1470.     }
  1471.       break;
  1472.  
  1473.     case CEIL_DIV_EXPR:
  1474.     case CEIL_MOD_EXPR:
  1475.       if (! can_clobber_op0)
  1476.     adjusted_op0 = copy_to_suggested_reg (adjusted_op0, target);
  1477.       if (log < 0)
  1478.     {
  1479.       rtx label = 0;
  1480.       if (! unsignedp)
  1481.         {
  1482.           label = gen_label_rtx ();
  1483.           emit_cmp_insn (adjusted_op0, const0_rtx, 0, 0, 0);
  1484.           emit_jump_insn (gen_ble (label));
  1485.         }
  1486.       expand_inc (adjusted_op0, op1);
  1487.       expand_dec (adjusted_op0, const1_rtx);
  1488.       if (! unsignedp)
  1489.         emit_label (label);
  1490.     }
  1491.       else
  1492.     {
  1493.       adjusted_op0 = expand_binop (GET_MODE (target), add_optab,
  1494.                        adjusted_op0, plus_constant (op1, -1),
  1495.                        0, 0, OPTAB_LIB_WIDEN);
  1496.     }
  1497.       mod_insn_no_good = 1;
  1498.       break;
  1499.  
  1500.     case ROUND_DIV_EXPR:
  1501.     case ROUND_MOD_EXPR:
  1502.       if (! can_clobber_op0)
  1503.     adjusted_op0 = copy_to_suggested_reg (adjusted_op0, target);
  1504.       if (log < 0)
  1505.     {
  1506.       op1 = expand_shift (RSHIFT_EXPR, mode, op1, integer_one_node, 0, 0);
  1507.       if (! unsignedp)
  1508.         {
  1509.           rtx label = gen_label_rtx ();
  1510.           emit_cmp_insn (adjusted_op0, const0_rtx, 0, 0, 0);
  1511.           emit_jump_insn (gen_bge (label));
  1512.           expand_unop (mode, neg_optab, op1, op1, 0);
  1513.           emit_label (label);
  1514.         }
  1515.       expand_inc (adjusted_op0, op1);
  1516.     }
  1517.       else
  1518.     {
  1519.       op1 = gen_rtx (CONST_INT, VOIDmode, INTVAL (op1) / 2);
  1520.       expand_inc (adjusted_op0, op1);
  1521.     }
  1522.       mod_insn_no_good = 1;
  1523.       break;
  1524.     }
  1525.  
  1526.   if (rem_flag && !mod_insn_no_good)
  1527.     {
  1528.       /* Try to produce the remainder directly */
  1529.       if (log >= 0)
  1530.     {
  1531.       return expand_bit_and (mode, adjusted_op0,
  1532.                  gen_rtx (CONST_INT, VOIDmode,
  1533.                       INTVAL (op1) - 1),
  1534.                  target);
  1535.     }
  1536.       else
  1537.     {
  1538.       /* See if we can do remainder without a library call.  */
  1539.       temp = sign_expand_binop (mode, umod_optab, smod_optab,
  1540.                     adjusted_op0, op1, target,
  1541.                     unsignedp, OPTAB_WIDEN);
  1542.       if (temp != 0)
  1543.         return temp;
  1544.       /* No luck there.
  1545.          Can we do remainder and divide at once without a library call?  */
  1546.       temp = gen_reg_rtx (mode);
  1547.       if (expand_twoval_binop (unsignedp ? udivmod_optab : sdivmod_optab,
  1548.                    adjusted_op0, op1,
  1549.                    0, temp, unsignedp))
  1550.         return temp;
  1551.       temp = 0;
  1552.     }
  1553.     }
  1554.  
  1555.   /* Produce the quotient.  */
  1556.   if (log >= 0)
  1557.     temp = expand_shift (RSHIFT_EXPR, mode, adjusted_op0,
  1558.              build_int_2 (exact_log2 (INTVAL (op1)), 0),
  1559.              target, unsignedp);
  1560.   else if (rem_flag && !mod_insn_no_good)
  1561.     /* If producing quotient in order to subtract for remainder,
  1562.        and a remainder subroutine would be ok,
  1563.        don't use a divide subroutine.  */
  1564.     temp = sign_expand_binop (mode, udiv_optab, sdiv_optab,
  1565.                   adjusted_op0, op1, target,
  1566.                   unsignedp, OPTAB_WIDEN);
  1567.   else
  1568.     temp = sign_expand_binop (mode, udiv_optab, sdiv_optab,
  1569.                   adjusted_op0, op1, target,
  1570.                   unsignedp, OPTAB_LIB_WIDEN);
  1571.  
  1572.   /* If we really want the remainder, get it by subtraction.  */
  1573.   if (rem_flag)
  1574.     {
  1575.       if (temp == 0)
  1576.     {
  1577.       /* No divide instruction either.  Use library for remainder.  */
  1578.       temp = sign_expand_binop (mode, umod_optab, smod_optab,
  1579.                     op0, op1, target,
  1580.                     unsignedp, OPTAB_LIB_WIDEN);
  1581.     }
  1582.       else
  1583.     {
  1584.       /* We divided.  Now finish doing X - Y * (X / Y).  */
  1585.       temp = expand_mult (mode, temp, op1, temp, unsignedp);
  1586.       if (! temp) abort ();
  1587.       temp = expand_binop (mode, sub_optab, op0,
  1588.                    temp, target, unsignedp, OPTAB_LIB_WIDEN);
  1589.     }
  1590.     }
  1591.  
  1592.   if (temp == 0)
  1593.     abort ();
  1594.   return temp;
  1595. }
  1596.  
  1597. /* Return a tree node with data type TYPE, describing the value of X.
  1598.    Usually this is an RTL_EXPR, if there is no obvious better choice.  */
  1599.  
  1600. static tree
  1601. make_tree (type, x)
  1602.      tree type;
  1603.      rtx x;
  1604. {
  1605.   tree t;
  1606.   switch (GET_CODE (x))
  1607.     {
  1608.     case CONST_INT:
  1609.       t = build_int_2 (INTVAL (x), 0);
  1610.       TREE_TYPE (t) = type;
  1611.       return fold (t);
  1612.  
  1613.     default:
  1614.       t = make_node (RTL_EXPR);
  1615.       TREE_TYPE (t) = type;
  1616.       RTL_EXPR_RTL (t) = x;
  1617.       /* There are no insns to be output
  1618.      when this rtl_expr is used.  */
  1619.       RTL_EXPR_SEQUENCE (t) = 0;
  1620.       return t;
  1621.     }
  1622. }
  1623.  
  1624. /* Return an rtx representing the value of X * MULT + ADD.
  1625.    MODE is the machine mode for the computation.
  1626.    UNSIGNEDP is non-zero to do unsigned multiplication.
  1627.    This may emit insns.  */
  1628.  
  1629. rtx
  1630. expand_mult_add (x, mult, add, mode, unsignedp)
  1631.      rtx x, mult, add;
  1632.      enum machine_mode mode;
  1633.      int unsignedp;
  1634. {
  1635.   tree type = type_for_size (GET_MODE_BITSIZE (mode), unsignedp);
  1636.   tree prod = fold (build (MULT_EXPR, type, make_tree (type, x),
  1637.                make_tree (type, mult)));
  1638.   tree sum = fold (build (PLUS_EXPR, type, prod, make_tree (type, add)));
  1639.   return expand_expr (sum, 0, VOIDmode, 0);
  1640. }
  1641.